package com.zmd.jdbc;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import com.zmd.ioc.User;

@Repository
public class UserDAO {
	@Autowired
	private JdbcTemplate jdbcTemplate;
	
	public void createUser() {
		String sqlString = "INSERT INTO user (name) VALUES ('zmd')";
		jdbcTemplate.execute(sqlString);
	}
	
	public User getUser() {
		return jdbcTemplate.queryForObject("SELECT id id, name name FROM user WHERE id=0", User.class);
	}
}
